package smedi.ismedi.mobile.bff.controller.securityman;

import com.smedi.ismedi.securityman.api.dto.request.AddAssessmentRequest;
import com.smedi.ismedi.securityman.api.dto.request.AddOfficerAssessmentRequest;
import com.smedi.ismedi.securityman.api.dto.request.QueryOfficerAssessmentRequest;
import com.smedi.ismedi.securityman.api.dto.response.AssessmentRuleResponse;
import com.smedi.ismedi.securityman.api.dto.response.OfficerAssessmentResponse;
import com.smedi.ismedi.securityman.api.feign.RemoteOfficerAssessmentFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 干事考核
 *
 * @author xuyuanqiao
 * @date 2021/09/23
 */
@Slf4j
@Api(value = "干事考核管理接口", tags = {"干事考核管理接口"})
@RequestMapping(value = "/mobilebff/v1/OfficerAssessment")
@RestController
@AllArgsConstructor
public class OfficerAssessmentController {
    private final RemoteOfficerAssessmentFeignApi remoteOfficerAssessmentFeignApi;

    /**
     * 添加干事考核
     *
     * @param addOfficerAssessmentRequest 添加干事考核请求
     * @return ResponseData<OfficerAssessmentResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "添加干事考核")
    @PostMapping(value = "/add")
    ResponseData<OfficerAssessmentResponse> postAddOfficerAssessment(@Validated @RequestBody AddOfficerAssessmentRequest addOfficerAssessmentRequest) {
        return remoteOfficerAssessmentFeignApi.postAddOfficerAssessment(addOfficerAssessmentRequest);
    }

    /**
     * 添加干事考核关系
     *
     * @param addAssessmentRequestList 添加干事考核关系请求,可以传空数组，不能传空
     * @return ResponseData<Long>
     */
    @ApiOperation(httpMethod = "POST", value = "添加干事考核关系")
    @PostMapping(value = "/addAssessmentRuleRelation")
    ResponseData<OfficerAssessmentResponse> postAddAssessmentRuleRelation(@Validated @RequestBody(required = true) AddAssessmentRequest addAssessmentRequestList) {
        return remoteOfficerAssessmentFeignApi.postAddAssessmentRuleRelation(addAssessmentRequestList);
    }

    /**
     * 分页查询干事考核列表
     *
     * @param queryOfficerAssessmentRequest 分页查询干事考核列表请求
     * @return ResponseData<PaginationData < OfficerAssessmentResponse>>
     */
    @ApiOperation(httpMethod = "POST", value = "分页查询干事考核列表")
    @PostMapping(value = "/pageList")
    ResponseData<PaginationData<OfficerAssessmentResponse>> postQueryOfficerAssessmentPage(@Validated @RequestBody QueryOfficerAssessmentRequest queryOfficerAssessmentRequest) {
        return remoteOfficerAssessmentFeignApi.postQueryOfficerAssessmentPage(queryOfficerAssessmentRequest);
    }

    /**
     * 根据id查询干事考核详情
     *
     * @param officerAssessmentId 干事考核id
     * @return ResponseData<OfficerAssessmentResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "根据id查询干事考核详情")
    @GetMapping(value = "/detail")
    ResponseData<OfficerAssessmentResponse> getQueryOfficerAssessmentDetail(@RequestParam Long officerAssessmentId) {
        return remoteOfficerAssessmentFeignApi.getQueryOfficerAssessmentDetail(officerAssessmentId);
    }

    /**
     * 分页查询干事考核规则
     *
     * @param workNature   工作性质
     * @param checkContent 检查内容
     * @param pageNum      行数
     * @param pageSize     页码
     * @return ResponseData<PaginationData < AssessmentRuleResponse>>
     */
    @ApiOperation(httpMethod = "GET", value = "分页查询干事考核规则")
    @GetMapping(value = "/rulePageList")
    ResponseData<PaginationData<AssessmentRuleResponse>> getQueryAssessmentRulePage(@RequestParam(value = "workNature", required = false) String workNature,
                                                                                    @RequestParam(value = "checkContent", required = false) String checkContent,
                                                                                    @RequestParam(value = "pageNum", required = true) Long pageNum,
                                                                                    @RequestParam(value = "pageSize", required = true) Long pageSize) {
        return remoteOfficerAssessmentFeignApi.getQueryAssessmentRulePage(workNature, checkContent, pageNum, pageSize);
    }

    /**
     * 确认考核结果
     *
     * @param assessmentResult    考核结果
     * @param assessmentTimeId    考核时间id
     * @param officerManagementId 干事id
     * @return ResponseData<Boolean>
     */
    @ApiOperation(httpMethod = "GET", value = "确认考核结果")
    @GetMapping(value = "/confirmAssessment")
    ResponseData<Boolean> getConfirmAssessment(@RequestParam(value = "assessmentResult", required = true) String assessmentResult,
                                               @RequestParam(value = "assessmentId", required = true) Long assessmentTimeId,
                                               @RequestParam(value = "officerManagementId", required = true) Long officerManagementId) {
        return remoteOfficerAssessmentFeignApi.getConfirmAssessment(assessmentResult, assessmentTimeId, officerManagementId);
    }

}
